<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title>发布新留言</title>
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/css/bootstrap.min.css">
</head>
<body>
<nav class="navbar navbar-expand-lg navbar-dark bg-dark">
    <div class="container">
        <a class="navbar-brand" href="#">留言板系统</a>
        <div class="navbar-collapse">
            <ul class="navbar-nav me-auto">
                <li class="nav-item">
                    <a class="nav-link" href="/messages">留言列表</a>
                </li>
                <li class="nav-item">
                    <a class="nav-link active" href="/messages/add">发布留言</a>
                </li>
            </ul>
            <span class="navbar-text me-3" th:text="'欢迎，' + ${session.currentUser.studentName}"></span>
            <a href="/logout" class="btn btn-outline-light">退出</a>
        </div>
    </div>
</nav>

<div class="container mt-4">
    <div class="row justify-content-center">
        <div class="col-md-8">
            <h2 class="mb-4">发布新留言</h2>
            <form th:action="@{/messages}" th:object="${message}" method="post">
                <div class="mb-3">
                    <label for="title" class="form-label">标题</label>
                    <input type="text" class="form-control" id="title" th:field="*{title}" required>
                </div>

                <div class="mb-3">
                    <label for="content" class="form-label">内容</label>
                    <textarea class="form-control" id="content" th:field="*{content}" rows="5" required></textarea>
                </div>

                <div class="d-grid gap-2 d-md-flex justify-content-md-end">
                    <a href="/messages" class="btn btn-secondary me-md-2">取消</a>
                    <button type="submit" class="btn btn-primary">发布</button>
                </div>
            </form>
        </div>
    </div>
</div>

<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/js/bootstrap.bundle.min.js"></script>
</body>
</html>